home *** CD-ROM | disk | FTP | other *** search
- /*
- ** VERUSR.C [edit EMAIL.H before compiling]
- **
- ** This program verifies an email user.
- **
- ** In order to verify a user, you must first connect to the
- ** SMTP server containing the user. Some SMTP servers may
- ** refuse this information because of security concerns.
- ** Also, note that connecting to some SMTP servers can be
- ** very slow.
- **
- ** Also see the BCAST example program.
- */
-
- #include <windows.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "see.h"
- #include "email.h"
-
- #define QUOTE 0x22
-
- static char Buffer[512];
-
- static LPSTR UserPtr;
- static LPSTR DomainPtr;
-
- /* display error message */
-
- static void ShowError(int Code, LPSTR Msg)
- {printf("ERROR: ");
- if(Msg) printf("%s\n",Msg);
- if(Code)
- {seeErrorText(Code,(LPSTR)Buffer,50);
- printf("%s\n",(LPSTR)Buffer);
- }
- }
-
- void main(int argc, char *argv[])
- {int i, Code;
- int Version;
- LPSTR Ptr;
-
- if(argc<2)
- {printf("Usage: VERUSR user1 user2 ...\n");
- printf(" eg: VERUSR msc@traveller.com lillian@ro.com\n");
- exit(1);
- }
-
- /* display parameters */
-
- Version = seeStatistics(SEE_GET_VERSION);
- printf("SEE4C Version %1x.%1x.%1x\n",0x0f&(Version>>8),0x0f&(Version>>4),0x0f&Version);
-
- /* define diagnostics log file */
- ///seeStringParam(SEE_LOG_FILE, (LPSTR)"verusr.log");
-
- for(i=1;i<argc;i++)
- {printf("%2d: ",i);
- if(strchr(argv[i],'<')) strcpy(Buffer,argv[i]);
- else
- {/* add '<>' brackets */
- strcpy(Buffer, "<");
- strcat(Buffer, argv[i]);
- strcat(Buffer, ">");
- }
- Code = seeVerifyFormat((LPSTR)Buffer);
- if(Code<0)
- {printf("Improper format [%s].\n",Buffer);
- continue;
- }
-
- Ptr = strchr(Buffer,'@');
- if(Ptr)
- {*Ptr = '\0';
- UserPtr = &Buffer[1];
- DomainPtr = Ptr + 1;
- Ptr = strchr(DomainPtr,'>');
- if(Ptr) *Ptr = '\0';
- }
- else
- {printf("ERROR in email address\n");
- continue;
- }
-
- /* connect to SMTP server */
- printf("Connecting to %c%s%c ...",QUOTE,(LPSTR)DomainPtr,QUOTE);
- Code = seeSmtpConnect(
- (LPSTR)DomainPtr, /* SMTP server */
- (LPSTR)YOUR_EMAIL_ADDR, /* return email address */
- (LPSTR)NULL); /* Reply-To header */
- if(Code<0)
- {ShowError(Code, "FAILS.\n");
- continue;
- }
-
- /* verify the user */
- printf("OK. %c%s%c is ",QUOTE,(LPSTR)UserPtr,QUOTE);
- Code = seeVerifyUser((LPSTR)UserPtr);
- if(Code==0)
- {seeDebug(SEE_GET_LAST_RESPONSE, (LPSTR)Buffer, 128);
- printf("NOT verified (%s).\n",Buffer);
- }
- else printf("verified.\n");
- seeClose();
- }
- printf("Done.\n");
- } /* end main */
-
-
-